import 'package:flutter/material.dart';
import 'package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart';

class BannerSwiper extends StatelessWidget {
  const BannerSwiper({
    Key? key,
    required this.itemBuilder,
    required this.bannerLength,
    this.control: false,
    this.showPagination: true,
    this.autoPlay: true,
    this.onItemClickListener,
    this.loop = true,
  }) : super(key: key);

  final IndexedWidgetBuilder itemBuilder;
  final SwiperOnTap? onItemClickListener;

  final int bannerLength;

  final bool control;
  final bool showPagination;
  final bool autoPlay;
  final bool loop;

  @override
  Widget build(BuildContext context) {
    return Swiper(
      autoplay: autoPlay,
      itemBuilder: itemBuilder,
      itemCount: bannerLength,
      onTap: onItemClickListener,
      loop: loop,
      pagination: showPagination
          ? SwiperPagination(
              builder: DotSwiperPaginationBuilder(
                activeColor: Colors.white,
                size: 8,
                activeSize: 8,
                color: const Color.fromRGBO(188, 188, 188, 1),
              ),
            )
          : null,
      control: control ? SwiperControl() : null,
    );
  }
}
